package com.sos.model.vo;

import lombok.Data;

import java.io.Serializable;

@Data
public class ResultVO<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    private int code;
    private String message;
    private T data;

    private ResultVO() {}

    public static <T> ResultVO<T> success() {
        ResultVO<T> result = new ResultVO<>();
        result.code = 200;
        result.message = "成功";
        return result;
    }

    public static <T> ResultVO<T> success(T data) {
        ResultVO<T> result = new ResultVO<>();
        result.code = 200;
        result.message = "成功";
        result.data = data;
        return result;
    }

    public static <T> ResultVO<T> error(int code, String message) {
        ResultVO<T> result = new ResultVO<>();
        result.code = code;
        result.message = message;
        return result;
    }
}
